package com.panku.service.impl;

import com.panku.dao.UserDao;
import com.panku.entity.User;
import com.panku.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

/**
 * @Author: jack
 * @Description:
 * @Date Create in 10:02 2021-01-21
 **/
@Service
public class UserService implements IUserService {

    @Autowired
    private UserDao userDao;

    public void saveUser(User user) {
        userDao.save(user);
    }

    public Page userPages(Integer page, Integer size) {
        Page<User> userPages = userDao.findAll(PageRequest.of(page, size));
        return userPages;
    }

    public User getUserById(Integer id) {
        return userDao.findById(id).get();
    }


}
